package easy

import (
	"fmt"
	"sort"
	"strconv"
)

type ListNode struct {
	Val  int
	Next *ListNode
}

func maxInt(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func passInt(nums [][]int) [][]int {
	m := make(map[string]int, len(nums))
	for i := 0; i < len(nums); i++ {
		sort.Ints(nums[i])
		str := ""
		for _, v := range nums[i] {
			str += strconv.Itoa(v)
		}
		if _, ok := m[str]; ok {
			continue
		}
		m[str] = i
	}
	res := make([][]int, 0, len(m))
	for _, i := range m {
		res = append(res, nums[i])
	}
	return res
}

func all(nums []int) [][]int {
	var result [][]int
	getAllMay(nums, 0, &result)
	return result
}
func getAllMay(nums []int, index int, result *[][]int) {
	if index == len(nums)-1 {
		data := make([]int, len(nums)) //注意这里不能设置size长
		copy(data, nums)
		*result = append(*result, data)
		return
	}
	for i := index; i < len(nums); i++ {
		nums[index], nums[i] = nums[i], nums[index]
		getAllMay(nums, index+1, result)
		nums[index], nums[i] = nums[i], nums[index]
	}
}

func scan(v any) {
	println(fmt.Sprintf("v:%v", v))
}
